<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>确认支付</title>
    <link rel="stylesheet" href="../css/aui.2.0.css">
    <link rel="stylesheet" href="../css/confirm-pay.css">
</head>
<body style="background-color: #f0f0f0">
<header class="aui-bar aui-bar-nav">
    <a class="aui-pull-left aui-btn">
        <span class="aui-iconfont aui-icon-left"></span>
    </a>
    <div class="aui-title">确认订单</div>
</header>
<nav>
    <div class="con-money">
        需支付: <span><span id="order-sales"></span>元</span>
    </div>
    <div class="con-pay-method">
        <!--<div class="con-pay-wechat">
            <div class="con-pay-left">
                <img src="../img/wx_pay.png" alt="">
                <span>微信支付</span>
                <span>微信安全支付</span>
            </div>
            <input class="aui-radio con-pay-select" checked type="radio" name="radio1" value="1">
        </div>-->
        <div class="con-pay-wechat">
            <div class="con-pay-left">
                <img src="../img/zfb.png" alt="">
                <span>支付宝支付</span>
                <span>支付宝安全支付</span>
            </div>
            <input class="aui-radio con-pay-select" type="radio" name="radio1" value="2">
        </div>
    </div>
    <div class="con-confirm-pay" id="confirm-pay">确认支付</div>
</nav>

<script src="../js/jquery-3.0.0.min.js"></script>
<script src="../js/config.js"></script>
<script src="../js/common.js"></script>
<!--<script src="../js/confirm-pay.js"></script>-->
<script>


    var totalMoney=localStorage.getItem('totalMoney');
    var orderId=localStorage.getItem('orderId');

    $('#order-sales').html(totalMoney);

    var payMethod=$('input[name=radio1]:checked').val();
    console.log(payMethod);

    $('.con-pay-select').click(function () {

        //获取支付方式，1为微信，2为支付宝
        payMethod=$('input[name=radio1]:checked').val();
    });

    $('#confirm-pay').bind('click',submitOrder);

    function submitOrder() {
        var payData={
            postType:'goPay',
            orderId:orderId,
            token:C.token,
            method:payMethod
        };
        console.log(payData);

        var ua = navigator.userAgent.toLowerCase();
        if (/iphone|ipad|ipod/.test(ua)) {
            iosGoPay(payData);

        } else {
            androidGoPay(JSON.stringify(payData));
        }

    }

    //android调用支付方法。
    function androidGoPay(param) {
        window.huifa.goPay(param);
    }

    function iosGoPay(param) {
        window.webkit.messageHandlers.goPay.postMessage(param);
    }
</script>

</body>
</html>